\documentclass[11pt]{article}
%\usepackage[firstpage]{draftwatermark}
\usepackage{times}
\usepackage{pdfpages}
\usepackage{fullpage}
\usepackage{url}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{enumitem}
\setlist{nosep} % or \setlist{noitemsep} to leave space around whole list
\usepackage{indentfirst}
\usepackage{subcaption}
\usepackage{units}
\usepackage{bm}
\usepackage{algorithm}
\usepackage{algorithmic}

\usepackage{./math_bbing}


% Highlighting
\usepackage{color,soul}
\DeclareRobustCommand{\hlr}[1]{{\sethlcolor{red}\hl{#1}}}
\DeclareRobustCommand{\hlg}[1]{{\sethlcolor{green}\hl{#1}}}
\DeclareRobustCommand{\hlb}[1]{{\sethlcolor{blue}\hl{#1}}}
\DeclareRobustCommand{\hly}[1]{{\sethlcolor{yellow}\hl{#1}}}

\setcounter{secnumdepth}{4}
\graphicspath{{images/}}
\pagestyle{fancy}

% Conditional for notes
\newif\ifnotes
\notesfalse


\newcommand{\doctitle}{Wave Generation}

\newcommand{\docnumber}{\doctitle}

\addtolength{\headheight}{2em}
\addtolength{\headsep}{1.5em}
\lhead{\docnumber}
\rhead{}

\newcommand{\capt}[1]{\caption{\small \em #1}}

\cfoot{\small Brian Bingham \today \\ \thepage}
\renewcommand{\footrulewidth}{0.4pt}

\newenvironment{xitemize}{\begin{itemize}\addtolength{\itemsep}{-0.75em}}{\end{itemize}}
\newenvironment{tasklist}{\begin{enumerate}[label=\textbf{\thesubsubsection-\arabic*},ref=\thesubsubsection-\arabic*,leftmargin=*]}{\end{enumerate}}
\newcommand\todo[1]{{\bf TODO: #1}}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{4}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

%\renewcommand{\chaptername}{Volume}
%\renewcommand{\thesection}{\Roman{section}}
%\renewcommand{\thesubsection}{\Roman{section}-\Alph{subsection}}

\begin{document}
\input{./Commands}  
\input{./defs}
\newpage
% Title Page
\setcounter{page}{1}
\begin{center}
{\huge \doctitle}
\end{center}


\section{Gerstner Wave Model}

Using \cite{tessendorf99simulating}, \cite{gpugems_waves} and \cite{frechot06realistic} the wave field is generated by summation of Gersnter waves at a nominal location ($\Vi{x_o} = \{x_o, y_o\}$) to generate a wave height $z$ at the location $\V{x} = \{x, y\}$
\begin{eqnarray}
  \V{x} & = & \Vi{x}{o} - \sum_{i=1}^{N} q_i A_i \sin(\Vi{k}{i} \cdot \Vi{x}{o} - \omega_i t + \phi_i) \\
  z & = & \sum_{i=1}^N A_i \cos(\Vi{k}{i} \cdot \Vi{x}{o} - \omega_i t + \phi_i)
  \label{e:gerstner}
\end{eqnarray}
where for each component wave $q_i$ is the steepness, $A_i$ is the amplitude, $\Vi{k}{i}$ is the wavevector, $\omega_i$ is the angular frequency and $\phi_i$ is the phase.  The wavevector is a horizontal vector in the direction of travel of the wave with the magnitude equal to the wavenumber, $k=2\pi/\lambda$, where $\lambda$ is the wavelength.  The wavenumber and angular frequency are related through the deep water dispersion relation
\begin{equation}
  \omega^2 = gk.
\end{equation}

\subsection{Startup Transient}
To address large forces due to transients at the start of the simulation, we modulate the wave height using a user-specified time constant $\tau$ so that the actual wave height is
\begin{equation}
  z  =  (1 - e^{-t/\tau}) \sum_{i=1}^N A_i \cos(\Vi{k}{i} \cdot \Vi{x}{o} - \omega_i t + \phi_i)
  \end{equation}

\section{Wavefield Models}

The properties of the component waves (\ref{e:gerstner}) are derived from a user-specified wavefield model.  We currently support the following two wavefield models:
\begin{enumerate}
\item Pierson-Moskowitz wave spectrum sampling (PMS)
\item Constant wavelength-amplitude ratio (CWR) as described in \cite{gpugems_waves}
\end{enumerate}
We use a common set of user-specified parameters for the wavefield model.

\subsection{User-Specified Wavefield Model Parameters}

Because we use a common set of wavefield model parameters to specify two possible models, the interpretation of some the parameters changes with the chosen model.
\begin{description}
\item[number ($N$)]: Same for PMS and CWR. The number of component waves.  Currently the visual implementation in GernstnerWaves.vert is limited to no more than three, so $N \leq 3$.
\item[steepness ($q$)]: Same for PMS and CWR. Steepness factor for Gernstner Waves - see Tessendorf, Simulating Ocean Waves. 
\item[period ($\bar{T}$)]:
  \begin{itemize}
  \item PMS: Specifies the peak of the P-M spectra.
  \item CWR: Median period, which specifies the median wavelength via the deep water dispersion relationship.
  \end{itemize}
\item[amplitude ($\bar{A}$)]:
  \begin{itemize}
  \item CWR: Not used.  Amplitude for each component is determiend by P-M spectrum.
  \item PMS: The median amplitude.  The ratio of median amplitude and median wavelength is held constant.
  \end{itemize}
\item[scale ($s$)]:
  \begin{itemize}
  \item PMS: A sampling scale factor specifying the multiplier on the angular frequency to sample successive wave components.  Typically 1.5.
  \item CWR: A scale factor specifying the wavelength/wavenumber spacing between successive wave components.  Typically 2.0.
  \end{itemize}
\item[gain ($\gamma$)]:
  \begin{itemize}
  \item PMS: Multiplier applied to the amplitude components.
  \item CWR: Not used
  \end{itemize}
\item[direction ($\bar{\V{d}}=\{d_x,d_y\}=\angle{\theta_d}$)]: Same for PMS and CWR. Mean direction of wave field, expressed as 2D unit vector
\item[angle ($a$)]: Same for PMS and CWR. Incremental angle relative to specified mean direction for generating individual component waves.
\item[tau ($\tau$)]: Same for PMS and CWR.  Time constant for gradualy increasing wave field.  
\end{description}

\subsection{Pierson-Moskowitz wave spectrum sampling (PMS)}

The Pierson-Moskowitz spectrum can be expressed as
\begin{equation}
S_{PM}(\omega)=\frac{\alpha g^2}{\omega^5} \exp{\left[ -\frac{5}{4} \left(\frac{\omega_p}{\omega}\right)^4 \right]}
\end{equation}

where $\alpha=8.1(10^{-3})$ and $\omega_p$ is the peak angular frequency.  We specify a geometric sampling where we use individual frequencies
\begin{equation}
  \omega_i = s^{i-(N-1)/2}\omega_p
\end{equation}
where the user sets th e scale value $s$ and the number of samples $N$.

\begin{figure}[hbt!]
\centerline{
{\includegraphics[width=0.8\textwidth]{pm_ex.png}}}
\caption{P-M spectrum example.}
\label{f:pm}
\end{figure}

The amplitude is determined from the spectrum by
\[
a_i^2 = 2 S(\omega_i) \Delta_i
\]
where $\Delta_i$ is the frequency spacing between samples. For $N=3$ this spacing is
\begin{eqnarray}
  i=0 & : & \Delta_0 = \omega_p(1-1/s) \\
  i=1 & : & \Delta_1 = \omega_p \frac{ s - 1/s}{s} \\
  i=2 & : & \Delta_2 = \omega_p (s-1).
\end{eqnarray}
We also include a gain value ($\gamma$) as a multiplier of the amplitude so that
\[
A_i = \gamma a_i = \gamma \sqrt{ 2 S(\omega_i) \Delta_i}
\]


\subsection{Constant Wavelength-Amplitude Ratio (CWR) Wavefield Model}

This model for generating the component waves is described in \cite{gpugems_waves}.  The general idea is that the user specifies the median wavelength and median amplitude.  The ratio of wavelength/amplitude is held constant, so longer wavelength/period waves tend to dominate the wave field. The median wavelength is specified indirectly via the median period, which is then used to calculate the median angular frequency and then the median wavenumber via the dispersion relationship.

\begin{algorithm}
  \caption{Constant Wavelength-Amplitude Ratio (CWR) Wavefield Model}
  \begin{algorithmic}
    \STATE $\bar{\omega} = \frac{2 \pi}{\bar{T}}$ (Median angular freq.)
    \STATE $\bar{k}= \frac{\bar{\omega}^2}{g}$ (Median wavenumber/lenght, via deep water dispersion)
    \STATE $i = 0$
    \FOR{$i<N$}
    \STATE $n=i - N/2$
    \STATE $A_i = \bar{A} (s^n)$
    \STATE $k_i = \frac{\bar{k}}{s^n}$
    \STATE $\omega_i = \sqrt{g k_i} = \bar{\omega}/ \sqrt{s^n}$
    \STATE $T_i = \bar{T} \sqrt{s^n}$
    \STATE $\Vi{d}{i} = \angle{(\theta_d + (n)(a))}$
    \STATE $\Vi{k}{i} = k_i \Vi{d}{i}$
    \STATE $q_i = \min{\{1.0, q/(A_i k_i N)\}}$
    \STATE $\phi_i = 0$
    \STATE $i++$
    \ENDFOR
  \end{algorithmic}
\end{algorithm}

\newpage
%\setcounter{page}{1}
\bibliographystyle{ieeetr}
\bibliography{refs}

\end{document}
